import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

/* Layout */
import Layout from '@/views/layout/Layout'

/** note: submenu only apppear when children.length>=1
*   detail see  https://panjiachen.github.io/vue-element-admin-site/#/router-and-nav?id=sidebar
**/

/**
* hidden: true                   if `hidden:true` will not show in the sidebar(default is false)
* alwaysShow: true               if set true, will always show the root menu, whatever its child routes length
*                                if not set alwaysShow, only more than one route under the children
*                                it will becomes nested mode, otherwise not show the root menu
* redirect: noredirect           if `redirect:noredirect` will no redirct in the breadcrumb
* name:'router-name'             the name is used by <keep-alive> (must set!!!)
* meta : {
    roles: ['admin','editor']     will control the page roles (you can set multiple roles)
    title: 'title'               the name show in submenu and breadcrumb (recommend set)
    icon: 'svg-name'             the icon show in the sidebar,
    noCache: true                if true ,the page will no be cached(default is false)
  }
**/
export const constantRouterMap = [
  { path: '/login', component: () => import('@/views/login/index'), hidden: true },
  { path: '/authredirect', component: () => import('@/views/login/authredirect'), hidden: true },
  { path: '/404', component: () => import('@/views/errorPage/404'), hidden: true },
  { path: '/401', component: () => import('@/views/errorPage/401'), hidden: true },
  {
    path: '',
    component: Layout,
    redirect: 'dashboard',
    children: [{
      path: 'dashboard',
      component: () => import('@/views/dashboard/index'),
      name: 'dashboard',
      meta: { title: '首页', icon: 'dashboard', noCache: true }
    }]
  }
]

export default new Router({
  // mode: 'history', // require service support
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRouterMap
})

export const asyncRouterMap = [

  {
    path: '/appointmentManage',
    component: Layout,
    redirect: 'noredirect',
    name: 'appointmentManage',
    meta: {
      title: '预约管理',
      icon: 'component'
    },
    children: [
      { path: 'appointmentConfirm', component: () => import('@/yimiviews/appointmentManage/appointmentConfirm'), name: 'appointmentConfirm', meta: { title: '预约确认' }},
      { path: 'surgeryConfirm', component: () => import('@/yimiviews/appointmentManage/surgeryConfirm'), name: 'surgeryConfirm', meta: { title: '手术确认' }}
    ]
  },

  {
    path: '/patientManage',
    component: Layout,
    children: [{
      path: 'index',
      component: () => import('@/yimiviews/patientManage/index'),
      name: 'patientManage',
      meta: { title: '患者管理', icon: 'tab' }
    }]
  },

  {
    path: '/followupManage',
    component: Layout,
    children: [{
      path: 'followup',
      component: () => import('@/yimiviews/followupManage/followup'),
      name: 'followup',
      meta: { title: '随访管理', icon: 'tab' }
    }]
  },

  {
    path: '/knowledgeManage',
    component: Layout,
    name: 'knowledgeManage',
    meta: {
      title: '知识库管理',
      icon: 'table'
    },
    children: [
      { path: 'followupForm', component: () => import('@/yimiviews/knowledgeManage/followupForm'), name: 'followupForm', meta: { title: '随访表单库' }},
      { path: 'healthPropaganda', component: () => import('@/yimiviews/knowledgeManage/healthPropaganda'), name: 'healthPropaganda', meta: { title: '健康宣教库' }},
      { path: 'operationDirectory', component: () => import('@/yimiviews/knowledgeManage/operationDirectory'), name: 'operationDirectory', meta: { title: '手术目录库' }},
      { path: 'operationScheduling', component: () => import('@/yimiviews/knowledgeManage/operationScheduling'), name: 'operationScheduling', meta: { title: '手术排班信息' }},
      { path: 'doctorInfomation', component: () => import('@/yimiviews/knowledgeManage/doctorInfomation'), name: 'doctorInfomation', meta: { title: '医生信息' }}
    ]
  },

  {
    path: '/systemManage',
    component: Layout,
    name: 'systemManage',
    meta: {
      title: '系统管理',
      icon: 'table'
    },
    children: [
      { path: 'hospitalManage', component: () => import('@/yimiviews/systemManage/hospitalManage'), name: 'hospitalManage', meta: { title: '医院管理', icon: 'tab' }}
    ]
  },

  { path: '*', redirect: '/404', hidden: true }
]
export const asyncRouterMap1 = [

  {
    path: '/components',
    component: Layout,
    redirect: 'noredirect',
    name: 'component-demo',
    meta: {
      title: 'components',
      icon: 'component'
    },
    children: [
      { path: 'tinymce', component: () => import('@/views/components-demo/tinymce'), name: 'tinymce-demo', meta: { title: 'tinymce' }},
      { path: 'splitpane', component: () => import('@/views/components-demo/splitpane'), name: 'splitpane-demo', meta: { title: 'splitPane' }},
      { path: 'sticky', component: () => import('@/views/components-demo/sticky'), name: 'sticky-demo', meta: { title: 'sticky' }},
      { path: 'mixin', component: () => import('@/views/components-demo/mixin'), name: 'componentMixin-demo', meta: { title: 'componentMixin' }},
      { path: 'back-to-top', component: () => import('@/views/components-demo/backToTop'), name: 'backToTop-demo', meta: { title: 'backToTop' }},
      { path: 'drag-dialog', component: () => import('@/views/components-demo/dragDialog'), name: 'dragDialog-demo', meta: { title: 'dragDialog' }},
      { path: 'drag-kanban', component: () => import('@/views/components-demo/dragKanban'), name: 'dragKanban-demo', meta: { title: 'dragKanban' }}
    ]
  },

  {
    path: '/tab',
    component: Layout,
    children: [{
      path: 'index',
      component: () => import('@/views/tab/index'),
      name: 'tab',
      meta: { title: 'tab', icon: 'tab' }
    }]
  },

  {
    path: '/table',
    component: Layout,
    redirect: '/table/complex-table',
    name: 'table',
    meta: {
      title: 'Table',
      icon: 'table'
    },
    children: [
      { path: 'tree-table', component: () => import('@/views/table/treeTable/treeTable'), name: 'treeTableDemo', meta: { title: 'treeTable' }},
      { path: 'custom-tree-table', component: () => import('@/views/table/treeTable/customTreeTable'), name: 'customTreeTableDemo', meta: { title: 'customTreeTable' }},
      { path: 'complex-table', component: () => import('@/views/table/complexTable'), name: 'complexTable', meta: { title: 'complexTable' }}
    ]
  },

  {
    path: '/error',
    component: Layout,
    redirect: 'noredirect',
    name: 'errorPages',
    meta: {
      title: 'errorPages',
      icon: '404'
    },
    children: [
      { path: '401', component: () => import('@/views/errorPage/401'), name: 'page401', meta: { title: 'page401', noCache: true }},
      { path: '404', component: () => import('@/views/errorPage/404'), name: 'page404', meta: { title: 'page404', noCache: true }}
    ]
  },

  {
    path: '/excel',
    component: Layout,
    redirect: '/excel/export-excel',
    name: 'excel',
    meta: {
      title: 'excel',
      icon: 'excel'
    },
    children: [
      { path: 'export-selected-excel', component: () => import('@/views/excel/selectExcel'), name: 'selectExcel', meta: { title: 'selectExcel' }}
    ]
  },

  { path: '*', redirect: '/404', hidden: true }
]
